---
--- Created by admin.
--- DateTime: 2017/10/7 16:08
---


FuZhaiFJ = {}

FuZhaiFJ.xianShi = {}

FuZhaiFJ.renWu = {}

FuZhaiFJ.ChengJu = {}


FuZhaiFJ.xianShiFind=function()
    x, y = findMultiColorInRegionFuzzy(0xe2180a,"-6|-6|0xeb361e,3|-8|0xf34e2c,-69|54|0xf8f38e,-55|12|0xb5240b,-39|2|0xe8451b,-35|18|0xfef23e,-44|64|0x283468,-32|60|0x2c3551,11|52|0x080b17,-29|-6|0x2f353c,-2|12|0x717e8b", 85, 221, 184, 598, 289, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("点击限时奖励")
        return true
    end
end

FuZhaiFJ.chengJiuFind=function()
    x, y = findMultiColorInRegionFuzzy(0xe01b0d,"2|-4|0xe9321d,5|1|0xda0e07,-7|3|0x28211e,-16|9|0x705231,-39|7|0xface70,-57|19|0x28211d,-45|64|0xfefdf8,-22|71|0xfefad9,-6|48|0x27211d,-39|42|0xdbb777,-33|70|0x231c19,-11|-2|0x27211d,-61|12|0x28211e", 85, 368, 1143, 468, 1274, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("点击成就")
        return true
    end
end

FuZhaiFJ.renWuFind=function()
    x, y = findMultiColorInRegionFuzzy(0xd05a4d,"-32|-5|0x28211e,-61|31|0x28211e,-32|46|0x27211d,13|55|0x27211d,24|42|0x28211d,32|32|0x7c5428,30|-1|0x28211d,-34|-6|0x28211e,-32|47|0x27211d", 85, 246, 1147, 372, 1275, 0, 0)

    if x > -1 then
        shouzhi.click(x, y)
        logger.info("点击任务")
        return true
    end
end




FuZhaiFJ.xianShi.ui = function()

    x, y = findMultiColorInRegionFuzzy(0x93551f, "-11|11|0x85481a,9|6|0x83471a,22|4|0x241103,-27|4|0x000000,-24|28|0x4f2804,-64|26|0x654723,-51|48|0x011219,-171|30|0x684923,-283|21|0x221507,-370|19|0x221507,-101|32|0x6a4b24,-153|51|0x011318,-286|5|0xc23010,-406|5|0xc23010,-342|7|0xcb3311", 95, 205, 25, 719, 113, 0, 0)
    if x > -1 then
        logger.info("限时奖励界面")
        return true
    end
end


FuZhaiFJ.xianShi.uiClose = function()

    x, y = findMultiColorInRegionFuzzy(0x93551f, "-11|11|0x85481a,9|6|0x83471a,22|4|0x241103,-27|4|0x000000,-24|28|0x4f2804,-64|26|0x654723,-51|48|0x011219,-171|30|0x684923,-283|21|0x221507,-370|19|0x221507,-101|32|0x6a4b24,-153|51|0x011318,-286|5|0xc23010,-406|5|0xc23010,-342|7|0xcb3311", 95, 205, 25, 719, 113, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("限时奖励界面关闭")
        return true
    end
end

FuZhaiFJ.xianShi.findHongDong = function()

    x, y = findMultiColorInRegionFuzzy(0x3a6491, "-16|2|0x355a84,35|0|0x3c6592,-13|35|0x0b182f,33|35|0x0d1b30,64|34|0x122f4a,72|-6|0xf5512f,72|-2|0xe42616,71|2|0xdb0e07,67|-2|0xe82f1a,57|-3|0x4d7eac,57|3|0x33567f,63|10|0x253e61,9|-17|0x010e11", 95, 575, 228, 708, 1215, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("限时奖励查找活动")
        return true
    end
end

FuZhaiFJ.xianShi.hongDongUi = function()

    x, y = findMultiColorInRegionFuzzy(0xa06124, "-6|31|0x000000,-104|24|0x644622,-163|17|0x221507,-143|-4|0x221507,43|-93|0x2e1b0a,34|-81|0x281608,52|-89|0x2a1808,45|-73|0x000000,-57|-58|0x21170b", 95, 456, 21, 717, 209, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("活动界面")
        return true
    end
end

FuZhaiFJ.xianShi.hongDongUiClose = function()

    x, y = findMultiColorInRegionFuzzy(0xa06124, "-6|31|0x000000,-104|24|0x644622,-163|17|0x221507,-143|-4|0x221507,43|-93|0x2e1b0a,34|-81|0x281608,52|-89|0x2a1808,45|-73|0x000000,-57|-58|0x21170b", 95, 456, 21, 717, 209, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("活动界面关闭")
        return true
    end
end

FuZhaiFJ.xianShi.lingQu = function()

    x, y = findMultiColorInRegionFuzzy(0xa95721, "-9|-26|0x040b09,41|-26|0x040b09,41|38|0x040b09,-9|38|0x040b09,-45|6|0x040b09,-14|-9|0xc1692d,0|-9|0xc0682c,-15|21|0x7c4416", 95, 450, 235, 644, 1130, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("领取")
        return true
    end
end

FuZhaiFJ.renWu.lingQu = function()

    x, y = findMultiColorInRegionFuzzy(0xa65622, "79|-36|0xb1a59e,-50|2|0xb29f9d,18|51|0xb1a19e,75|50|0xb2a5a2,3|1|0x9f5220,-19|-14|0xc97230,50|-14|0xc77030,-14|20|0x7d4516,0|-1|0xa95721", 95, 487, 363, 689, 1277, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("领取")
        return true
    end
end

FuZhaiFJ.renWu.ui = function()
    x, y = findMultiColorInRegionFuzzy(0xfece2a, "1|21|0x940f0a,-10|6|0xfec013,6|3|0xfec61c,-19|-4|0xa41a0c,-75|5|0x73281c,-134|27|0x321500,-290|28|0x321500,-252|6|0x3b0b00,-303|-9|0xfef7c3,-304|-10|0xfef9c8,-304|-1|0xfee697,-337|-13|0xfefdd3,-337|3|0xfede81", 95, 230, 37, 718, 154, 0, 0)
    if x > -1 then
        logger.info("任务界面")
        return true
    end

end

FuZhaiFJ.renWu.uiClose = function()
    x, y = findMultiColorInRegionFuzzy(0xfece2a, "1|21|0x940f0a,-10|6|0xfec013,6|3|0xfec61c,-19|-4|0xa41a0c,-75|5|0x73281c,-134|27|0x321500,-290|28|0x321500,-252|6|0x3b0b00,-303|-9|0xfef7c3,-304|-10|0xfef9c8,-304|-1|0xfee697,-337|-13|0xfefdd3,-337|3|0xfede81", 95, 230, 37, 718, 154, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("任务界面关闭")
        return true
    end

end

FuZhaiFJ.renWu.hongYao = function()
    x, y = findMultiColorInRegionFuzzy(0x2c0406, "-20|4|0x511908,5|-26|0x2e0001,14|-21|0x9f9653,15|-13|0xc6b95e,16|-8|0xb4a732,16|5|0x968a2c,-36|-19|0xa69933", 85, 112, 146, 712, 337, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("领取活跃度")
        return true
    end
end


FuZhaiFJ.ChengJu.ui = function()

    x, y = findMultiColorInRegionFuzzy(0xfed839, "-20|0|0x9c150c,3|27|0x93100a,-66|28|0x321500,-81|46|0x292033,-223|44|0x292033,-243|5|0x3b0b00,-306|-10|0xfefdd4,-296|-4|0xfef4bb,-330|9|0xfeda76,-339|-9|0xfefcd1", 95, 225, 43, 719, 170, 0, 0)
    if x > -1 then
        logger.info("成就界面")
        return true
    end
end

FuZhaiFJ.ChengJu.uiClose = function()

    x, y = findMultiColorInRegionFuzzy(0xfed839, "-20|0|0x9c150c,3|27|0x93100a,-66|28|0x321500,-81|46|0x292033,-223|44|0x292033,-243|5|0x3b0b00,-306|-10|0xfefdd4,-296|-4|0xfef4bb,-330|9|0xfeda76,-339|-9|0xfefcd1", 95, 225, 43, 719, 170, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("成就界面关闭")
        return true
    end
end


FuZhaiFJ.ChengJu.findChengJu = function()

    x, y = findMultiColorInRegionFuzzy(0xe21a0c,"-1|-4|0xe82e1a,4|-7|0xf14528,5|-3|0xe01c10,-6|5|0x17151e,-10|-8|0x48454c,-6|-12|0x17151d,15|-1|0x19161f,14|2|0x15121a,12|8|0x48474d,0|0|0xe21a0c", 85, 102, 168, 162, 1223, 0, 0)
    if x == -1 then
        x, y = findMultiColorInRegionFuzzy(0xe1180a,"-3|-5|0xf04526,3|-6|0xeb3720,7|-2|0xdf1a0d,-11|-9|0x48464d,-14|-3|0x46454c,12|8|0x4c4b4e,2|12|0x4b484e,16|2|0x13121e,-9|-14|0x1a1922", 85, 457, 175, 519, 940, 0, 0)

    end
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("查找成就")
        return true
    end
end

FuZhaiFJ.ChengJu.xiangQingUi = function()

    x, y = findMultiColorInRegionFuzzy(0xfee34b, "-22|-3|0x1e2b43,1|24|0x1e2b43,21|-2|0x1e2b43,-174|-12|0x3b0b00,-354|-28|0xfefcd0,-342|-6|0xfed974,-354|-21|0xfef2b6,-302|-23|0xfef5bf,-261|-14|0xfee695,-281|-22|0xfef4bb,-277|-30|0xfefdd5,-261|-20|0xfef1b1", 95, 152, 177, 703, 314, 0, 0)
    if x > -1 then
        logger.info("成就详情界面")
        return true
    end
end


FuZhaiFJ.ChengJu.xiangQingUiClose = function()

    x, y = findMultiColorInRegionFuzzy(0xfee34b, "-22|-3|0x1e2b43,1|24|0x1e2b43,21|-2|0x1e2b43,-174|-12|0x3b0b00,-354|-28|0xfefcd0,-342|-6|0xfed974,-354|-21|0xfef2b6,-302|-23|0xfef5bf,-261|-14|0xfee695,-281|-22|0xfef4bb,-277|-30|0xfefdd5,-261|-20|0xfef1b1", 95, 152, 177, 703, 314, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("成就详情界面关闭")
        return true
    end
end

FuZhaiFJ.ChengJu.lingQu = function()
    x, y = findMultiColorInRegionFuzzy(0xc0672c, "36|0|0xc76d2e,90|0|0xc36b2e,7|33|0x532b18,44|34|0x502914,96|34|0x804716,-15|34|0x7d4415", 95, 471, 293, 657, 1039, 0, 0)
    if x > -1 then
        shouzhi.click(x, y)
        logger.info("成就领取")
        return true
    end
end




FuZhaiFJ.xianShi.run=function ()

    FuZhaiFJ.xianShiFind()
    if not  FuZhaiFJ.xianShi.ui() then
        return
    end


    -- 当前页面是否能已领取
    logger.info("进入限时奖励")
    for tmpi = 1, 3 do

        local pageChengJiu = true;
        while pageChengJiu do
            pageChengJiu = false;
            -- 领取
            logger.info("检测是否有奖励可以领取")
            local flag = FuZhaiFJ.xianShi.findHongDong()

            -- 检测领取页面
            local pageFlag2 = true;
            while flag do
                mSleep(1000)
                pageFlag2 = false;
                -- 检测领取按钮
                flag = true;
                while flag do
                    flag = FuZhaiFJ.xianShi.lingQu()
                    -- 当前页领取过
                    if flag then
                        pageFlag2 = true;
                    end
                    mSleep(2000)
                end
                -- 如果当前页领取过，则检测下一页
                if pageFlag2 then
                    pageChengJiu = true;
                    shouzhi.move(359,920, 358,280)
                end
                mSleep(1000)

            end
            FuZhaiFJ.xianShi.hongDongUiClose()
            mSleep(1000)
        end


        -- 如果当前页领取过，则检测下一页
        shouzhi.move(413,1094, 426,221)
        mSleep(1000)
    end

    FuZhaiFJ.xianShi.uiClose()
    logger.info("退出 《限时奖励》")
end



-- 任务
FuZhaiFJ.renWu.run=function ()

    FuZhaiFJ.renWuFind()
    if not  FuZhaiFJ.renWu.ui() then
        return
    end


    logger.info("进入 《任务》")
    -- 当前页面是否能已领取
    local pageFlag = true;
    while pageFlag do
        pageFlag = false;
        -- 领取
        local flag = true
        while flag do

            mSleep(2000)
            flag = FuZhaiFJ.renWu.lingQu()
            if flag then
                pageFlag = flag;
            end

        end

        if pageFlag then
            mSleep(1000)
            shouzhi.move(373,1134, 368,219)
        end

        mSleep(1000)
    end

    flag = true
    while flag do
        flag =  FuZhaiFJ.renWu.hongYao()
        mSleep(1000)
    end


    FuZhaiFJ.renWu.uiClose()
    logger.info("退出 《任务》")
end

-- 运行成就
FuZhaiFJ.ChengJu.run=function ()

    FuZhaiFJ.chengJiuFind()
    if not  FuZhaiFJ.ChengJu.ui() then
        return
    end

    logger.info("进入 《成就》")
    -- 当前页面是否能已领取

    for tmpi = 1, 3 do

        local pageChengJiu = true;
        while pageChengJiu do
            pageChengJiu = false;
            -- 领取
            logger.info("检测是否有成就可以领取")
            local flag = FuZhaiFJ.ChengJu.findChengJu()
            -- 检测领取页面
            local pageFlag2 = true;
            while flag do
                pageFlag2 = false;
                mSleep(1000)
                -- 检测领取按钮
                flag = true;
                while flag do
                    flag = FuZhaiFJ.ChengJu.lingQu()
                    -- 当前页领取过
                    if flag then
                        pageFlag2 = true;
                    end
                    mSleep(2000)
                end
                -- 如果当前页领取过，则检测下一页
                if pageFlag2 then
                    pageChengJiu = true;
                    shouzhi.move(576, 1100, 557, 470)
                end
                mSleep(1000)

            end
            FuZhaiFJ.ChengJu.xiangQingUiClose()
            mSleep(1000)
        end

        -- 如果当前页领取过，则检测下一页
        shouzhi.move(555, 1100, 539, 279)
        mSleep(1000)
    end

    FuZhaiFJ.ChengJu.uiClose()
    logger.info("退出 《成就》")
end

FuZhaiFJ.run=function()
    mSleep(500)
    if Setting.fuzhai_xianshi then
        FuZhaiFJ.xianShi.run()
        mSleep(1000)
    end


    if Setting.fuzhai_renwu then
        FuZhaiFJ.renWu.run()
        mSleep(1000)
    end


    if Setting.fuzhai_chengju then
        FuZhaiFJ.ChengJu.run()
        mSleep(1000)
    end



end



